package com.thiswhyme.discovery.server2.v1.controller;

import com.thiswhyme.common.response.ResponseVo;
import com.thiswhyme.discovery.server2.v1.dto.UserDto;
import com.thiswhyme.discovery.server2.v1.feign.UserFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by thiswhyme on 2020/8/16.
 */
@RestController
@RequestMapping("/user2/")
public class UserController {

    @Autowired
    private UserFeignService userFeignService;

    @GetMapping("user-list")
    public ResponseVo<List<UserDto>> listUsers() {
        System.out.println("=========listUsers======v1");
        return userFeignService.listUsers("server2-v1");
    }

    @GetMapping("user-name")
    public ResponseVo<String> queryUserName() throws InterruptedException {
        System.out.println("=========queryUserName======v1");
        Thread thread = new Thread(() -> {
            userFeignService.queryUserName("server2-v1").getData();
        });
        thread.run();
        return ResponseVo.success();
    }
}
